package com.hot;


import android.Manifest;
import android.app.Activity;
import android.content.Intent;
import android.graphics.Color;
import android.net.Uri;
import android.os.Bundle;
import android.text.TextUtils;
import android.view.View;
import android.webkit.WebView;

import com.CurrentAddressBean;
import com.JSData;
import com.PopupUtil;
import com.ReceivingAddressBean;
import com.UserAddressData;
import com.baselibrary.Constants;
import com.baselibrary.MessageBus;
import com.baselibrary.UserInfo;
import com.baselibrary.bean.CityData;
import com.baselibrary.bean.ReceiveAddressBean;
import com.baselibrary.manager.AppManager;
import com.baselibrary.manager.CityManager;
import com.baselibrary.manager.DialogManager;
import com.baselibrary.permission.PermissionsUtils;
import com.baselibrary.permission.callback.PermissionsCall;
import com.baselibrary.router.ActivityRouter;
import com.baselibrary.utils.ARouterUtils;
import com.baselibrary.utils.CommonUtil;
import com.baselibrary.utils.ContextUtils;
import com.baselibrary.utils.DoubleClickHelper;
import com.baselibrary.utils.EventBusUtils;
import com.baselibrary.utils.GsonUtils;
import com.baselibrary.utils.HKLogUtils;
import com.baselibrary.utils.SpUtils;
import com.baselibrary.utils.ToastUtils;
import com.bigkoo.pickerview.builder.OptionsPickerBuilder;
import com.bigkoo.pickerview.listener.OnOptionsSelectListener;
import com.bigkoo.pickerview.view.OptionsPickerView;
import com.github.lzyzsd.jsbridge.CallBackFunction;
import com.google.gson.JsonObject;
import com.jsbridge.R;
import com.okhttp.SendRequest;
import com.okhttp.callbacks.GenericsCallback;
import com.okhttp.callbacks.StringCallback;
import com.okhttp.sample_okhttp.JsonGenericsSerializator;

import org.json.JSONException;
import org.json.JSONObject;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;

import okhttp3.Call;

/**
 * @author 关忆北丶
 * @description:
 * @date :2021/4/21 15
 */
public class IPJsDispatchCallBack implements JsSignDispatchCallBack {
    private static final String TAG = "IPJsDispatchCallBack";
    private Activity mAct;
    public static final int H5_APPOINT_MAP_RES = 0X101;
    public static final int H5_APPOINT_MAP_RESULT = 0X102;
    public static final int H5_QUEST_RES = 0X103;//问卷
    public static long QUESTIONNAIRE_ID = -1;//问卷Id

    private CallBackFunction function;
    private String[] mCallPermissions = new String[]{Manifest.permission.CALL_PHONE};
    private WebView mWebView;

    public IPJsDispatchCallBack(Activity mAct, WebView mWebView) {
        this.mAct = mAct;
        this.mWebView = mWebView;
    }

    @Override
    public void getToken(CallBackFunction function) {
        JsonObject mJsonObject = new JsonObject();
        mJsonObject.addProperty("token", SpUtils.getInstance().getUserToken());
        HKLogUtils.e("============获取token" + mJsonObject.toString());
        function.onCallBack(mJsonObject.toString());
    }

    @Override
    public void onBack(CallBackFunction function) {
        EventBusUtils.sendNotify(MessageBus.msgId_finish_h5_page);
    }

    @Override
    public void appointMap(CallBackFunction function, JSData.ParamBean mParam) {
        this.function = function;
//        Intent mAppointMapIntent = new Intent(mAct, SignAppointMapActivity.class);
//        mAppointMapIntent.putExtra("appointMap", mParam);
//        mAct.startActivityForResult(mAppointMapIntent, H5_APPOINT_MAP_RES);
    }

    @Override
    public void jumpGroup(CallBackFunction function, JSData.ParamBean mParam) {
        this.function = function;
        reloadWeb();
    }

    @Override
    public void callPhone(CallBackFunction function, JSData.ParamBean mParam) {
        this.function = function;
        PermissionsUtils.getInstance().chekPermissions(mAct, mCallPermissions, new PermissionsCall() {
            @Override
            public void permissionsPass() {
                callPhone(mParam.getTel());
            }
        });
    }

    @Override
    public void questionnaireBtn(CallBackFunction function, JSData.ParamBean mParam) {
        this.function = function;
    }

    @Override
    public void fillQuestionnaireEnd(CallBackFunction function, JSData.ParamBean mParam) {
        this.function = function;
        mAct.finish();
    }

    @Override
    public void reLogin(CallBackFunction function, JSData.ParamBean mParam) {
        this.function = function;
    }

    @Override
    public void openAppServer(CallBackFunction function, JSData.ParamBean mParam) {
        this.function = function;
    }

    @Override
    public void getDeviceInfo(CallBackFunction function, JSData.ParamBean mParam) {
    }

    @Override
    public void getNfcData(CallBackFunction function, JSData.ParamBean mParam) {

    }

    //跳转 【话题详情】
    @Override
    public void jupmTopicDetail(CallBackFunction function, JSData.ParamBean mParam) {
        if (DoubleClickHelper.isOnDoubleClick()) return;
        Bundle bundle = new Bundle();
        bundle.putString("tid", String.valueOf(mParam.getTagId()));
        ActivityRouter.startActivity(ActivityRouter.COMMUNITY.COMMUNITY_TOPIC_DETAIL, bundle);
    }

    //跳转到动态详情(0,文本，1.图文，2.视频，4转发)
    @Override
    public void jumpDynamicDetail(CallBackFunction function, JSData.ParamBean mParam) {
        if (DoubleClickHelper.isOnDoubleClick()) return;
        switch (mParam.getType()) {
            case 0:
            case 1:
            case 4://图文详情
                HashMap<String, Object> hashMap = new HashMap<>();
                hashMap.put("id", String.valueOf(mParam.getId()));
                ARouterUtils.jump(ActivityRouter.ACTIVITY.IMAGE_DETAIL, hashMap);
                break;
            case 2://视频详情
//                AppUtils.openVideoRead(mParam.getId(), mParam.getTopicId() + "", 7, false);
                break;
        }
    }

    //显示 领取弹窗
    @Override
    public void showActiveRecivePop(CallBackFunction function, JSData.ParamBean mParam) {
    }

    @Override
    public void loadWineCoin(CallBackFunction function, JSData.ParamBean mParam) {
        if (TextUtils.isEmpty(mParam.getContent()) || !SpUtils.getInstance().getIsLogin())
            return;
        getWineCoin(mParam.getContent());
    }

    //金鳞瓶活动抢购
    @Override
    public void jumpJinLinRushBuy(CallBackFunction function, JSData.ParamBean mParam) {
    }

    @Override
    public void openOrCloseRulePop(CallBackFunction function, JSData.ParamBean mParam, boolean isOpen) {
        EventBusUtils.sendNotify1Value(MessageBus.msgid_open_close_reule_pop, isOpen);
    }

    //直接跳转选择支付页面（下单，未支付）
    @Override
    public void jumpJinLinRushPay(CallBackFunction function, JSData.ParamBean mParam) {
    }

    @Override
    public void UMBp(CallBackFunction function, JSData.ParamBean mParam) {
    }

    @Override
    public void goJinlinShare(CallBackFunction function, JSData.ParamBean mParam) {
//        mAct.startActivity(new Intent(mAct, SharePosterForJinlinActivity.class));
        if (SpUtils.getInstance().getIsLogin()) {
            EventBusUtils.sendNotify2Value(MessageBus.msgId_show_share, mParam.getId(), mParam.getLuckId());
        } else {
            ARouterUtils.jump(ActivityRouter.LOGIN.LOGIN_PAGE);
        }
    }

    @Override
    public void selectAddress(CallBackFunction function, JSData.ParamBean mParam) {
        this.function = function;
        ReceivingAddressBean.Address mAddress = new ReceivingAddressBean.Address();
        List<CityData> mCityList = CityManager.getInstance().getAreaFirst();

        ArrayList<String> mOptionsItemSheng = new ArrayList<>(); //省
        ArrayList<ArrayList<String>> mOptionsItemShi = new ArrayList<>();//市
        ArrayList<ArrayList<ArrayList<String>>> mOptionsItemQv = new ArrayList<>();//区


        for (int i = 0; i < mCityList.size(); i++) {
            ArrayList<String> options2Items_01 = new ArrayList<>();
            ArrayList<ArrayList<String>> options3Items_01 = new ArrayList<>();
            String province = mCityList.get(i).getName();
            for (int j = 0; j < mCityList.get(i).getChildren().size(); j++) {
                options2Items_01.add(mCityList.get(i).getChildren().get(j).getName());
                ArrayList<String> options3Items_01_01 = new ArrayList<>();
                for (int k = 0; k < mCityList.get(i).getChildren().get(j).getChildren().size(); k++) {
                    options3Items_01_01.add(mCityList.get(i).getChildren().get(j).getChildren().get(k).getName());
                }
                options3Items_01.add(options3Items_01_01);
            }
            mOptionsItemSheng.add(province);
            mOptionsItemShi.add(options2Items_01);
            mOptionsItemQv.add(options3Items_01);
        }


        OptionsPickerView pvOptions = new OptionsPickerBuilder(mAct, new OnOptionsSelectListener() {
            @Override
            public void onOptionsSelect(int options1, int options2, int options3, View v) {
                ArrayList<String> mCityName = new ArrayList<>();
                ArrayList<String> mCityId = new ArrayList<>();
                for (int i = 0; i < mCityList.size(); i++) {
                    if (mCityList.get(i).getId() == mCityList.get(options1).getId()) {
                        mCityName.add(mCityList.get(i).getName());
                        mCityId.add(mCityList.get(i).getId());
                        for (int j = 0; j < mCityList.get(i).getChildren().size(); j++) {
                            if (mCityList.get(i).getChildren().get(j).getId() == mCityList.get(options1).getChildren().get(options2).getId()) {
                                mCityName.add(mCityList.get(i).getChildren().get(j).getName());
                                mCityId.add(mCityList.get(i).getChildren().get(j).getId());
                            }
                            for (int k = 0; k < mCityList.get(i).getChildren().get(j).getChildren().size(); k++) {
                                if (mCityList.get(i).getChildren().get(j).getChildren().get(k).getId() == mCityList.get(options1).getChildren().get(options2).getChildren().get(options3).getId()) {
                                    mCityName.add(mCityList.get(i).getChildren().get(j).getChildren().get(k).getName());
                                    mCityId.add(mCityList.get(i).getChildren().get(j).getChildren().get(k).getId());
                                }
                            }
                        }
                    }
                }

                mAddress.setProvince(new ReceivingAddressBean.Address.AddressInfo(Long.parseLong(mCityId.get(0)), mCityName.get(0)));
                mAddress.setCity(new ReceivingAddressBean.Address.AddressInfo(Long.parseLong(mCityId.get(1)), mCityName.get(1)));
                mAddress.setDistrict(new ReceivingAddressBean.Address.AddressInfo(Long.parseLong(mCityId.get(2)), mCityName.get(2)));

                function.onCallBack(GsonUtils.toJson(mAddress));
            }
        })
                .setTitleText("城市选择")
                .setTitleBgColor(Color.WHITE)//设置标题的背景颜色
                .setDividerColor(Color.BLACK)//设置分割线的颜色
                .setTextColorCenter(Color.BLACK) //设置选中项文字颜色
                .setContentTextSize(20)
                .build();
        pvOptions.setPicker(mOptionsItemSheng, mOptionsItemShi, mOptionsItemQv);
        pvOptions.show();
    }

    //跳转地址列表选择地址
    @Override
    public void selectReceivingAddress(CallBackFunction function, JSData.ParamBean mParam) {
        this.function = function;
//        mAct.startActivityForResult(new Intent(mAct, EditAddressActivity.class).putExtra("type", 1), H5_APPOINT_MAP_RES);
        HashMap map = new HashMap<String, Object>();
        map.put("key_address_id", "0");
        ARouterUtils.jump(ActivityRouter.NEW_RETAIL.RECEIVE_ADDRESS, map);
    }

    @Override
    public void jumpSearchWineCellar(CallBackFunction function, JSData.ParamBean mParam) {
        this.function = function;
    }

    @Override
    public void jumpAPPRouter(CallBackFunction function, JSData.ParamBean mParam) {
        ARouterUtils.jump(mParam.getPage());
    }

    @Override
    public void getCurrentAddress(CallBackFunction function, JSData.ParamBean mParam) {
        this.function = function;
        CurrentAddressBean mReceivingAddressBean = new CurrentAddressBean();
        CurrentAddressBean.Address mAddress = new CurrentAddressBean.Address();
        if (CommonUtil.isLocationEnabled(mAct)) {
            mReceivingAddressBean.setType(1);
            mAddress.setProvince(SpUtils.getString(ContextUtils.getCurApplication(), "address_ProvinceName"));
            mAddress.setCity(SpUtils.getString(ContextUtils.getCurApplication(), "address_CityName"));
            mAddress.setDistrict(SpUtils.getString(ContextUtils.getCurApplication(), "address_AreaName"));
            mReceivingAddressBean.setAddress(mAddress);

        } else {
            mReceivingAddressBean.setType(0);
        }
        function.onCallBack(GsonUtils.toJson(mReceivingAddressBean));
    }

    @Override
    public void getAppHarvestAddress(CallBackFunction function, JSData.ParamBean mParam) {
        this.function = function;

        ReceivingAddressBean mReceivingAddressBean = new ReceivingAddressBean();
        ReceivingAddressBean.Address mAddress = new ReceivingAddressBean.Address();
        SendRequest.useraddress_getUserAddresses(SpUtils.getInstance().getLoadUserBean().getData().getToken(), new GenericsCallback<UserAddressData>(new JsonGenericsSerializator()) {
            @Override
            public void onError(Call call, Exception e, int id) {
                ToastUtils.showShort(mAct.getApplicationContext(), "网络异常，获取失败");
                function.onCallBack(GsonUtils.toJson(mReceivingAddressBean));
            }

            @Override
            public void onResponse(UserAddressData response, int id) {
                boolean isExistenceDef = false;
                if (response != null && response.isSuccess()) {
                    List<UserAddressData.DataBean> data = response.getData();
                    if (data.size() > 0) {
                        for (UserAddressData.DataBean datum : data) {
                            if (datum.getDef() == 1) {
                                isExistenceDef = true;
                                mReceivingAddressBean.setType(1);
                                ReceivingAddressBean.Address.AddressInfo mDistrictInfo = getAddressInfoBean(datum.getAreaThree());
                                if (mDistrictInfo != null) {
                                    mAddress.setDistrict(new ReceivingAddressBean.Address.AddressInfo(mDistrictInfo.id, mDistrictInfo.name));
                                }
                                ReceivingAddressBean.Address.AddressInfo mCityInfo = getAddressInfoBean(datum.getAreaSecond());
                                if (mCityInfo != null) {
                                    mAddress.setCity(new ReceivingAddressBean.Address.AddressInfo(mCityInfo.id, mCityInfo.name));
                                }
                                ReceivingAddressBean.Address.AddressInfo mProvinceInfo = getAddressInfoBean(datum.getAreaFirst());
                                if (mProvinceInfo != null) {
                                    mAddress.setProvince(new ReceivingAddressBean.Address.AddressInfo(mProvinceInfo.id, mProvinceInfo.name));
                                }
                                mAddress.setId(datum.getId());
                                mAddress.setName(datum.getName());
                                mAddress.setPhone(datum.getPhone());
                                mAddress.setAddress(datum.getAddress());
                                mReceivingAddressBean.setAddress(mAddress);
                                break;
                            }
                        }
                        if (!isExistenceDef) {
                            //没有默认地址取第一个
                            UserAddressData.DataBean datum = data.get(0);
                            mReceivingAddressBean.setType(1);
                            ReceivingAddressBean.Address.AddressInfo mDistrictInfo = getAddressInfoBean(datum.getAreaThree());
                            if (mDistrictInfo != null) {
                                mAddress.setDistrict(new ReceivingAddressBean.Address.AddressInfo(mDistrictInfo.id, mDistrictInfo.name));
                            }
                            ReceivingAddressBean.Address.AddressInfo mCityInfo = getAddressInfoBean(datum.getAreaSecond());
                            if (mCityInfo != null) {
                                mAddress.setCity(new ReceivingAddressBean.Address.AddressInfo(mCityInfo.id, mCityInfo.name));
                            }
                            ReceivingAddressBean.Address.AddressInfo mProvinceInfo = getAddressInfoBean(datum.getAreaFirst());
                            if (mProvinceInfo != null) {
                                mAddress.setProvince(new ReceivingAddressBean.Address.AddressInfo(mProvinceInfo.id, mProvinceInfo.name));
                            }
                            mAddress.setId(datum.getId());
                            mAddress.setName(datum.getName());
                            mAddress.setPhone(datum.getPhone());
                            mAddress.setAddress(datum.getAddress());
                            mReceivingAddressBean.setAddress(mAddress);
                        }
                    }
                }
                function.onCallBack(GsonUtils.toJson(mReceivingAddressBean));
            }
        });
    }

    private ReceivingAddressBean.Address.AddressInfo getAddressInfoBean(String areaThree) {
        return GsonUtils.parseJsonToBean(areaThree, ReceivingAddressBean.Address.AddressInfo.class);
    }

    //客户端添加地址并返回web回显
    @Override
    public void addAddress(CallBackFunction function, JSData.ParamBean mParam) {
        this.function = function;
        //重新编辑
//        mAct.startActivityForResult(new Intent(mAct, AddAddressActivity.class).putExtra("addFlag", 1), H5_APPOINT_MAP_RES);
        ARouterUtils.jump(ActivityRouter.NEW_RETAIL.EDIT_OR_ADD_NEW_ADDRESS);
    }

    @Override
    public void registerOver(CallBackFunction function, JSData.ParamBean mParam) {
        //会员登记点击提交
        PopupUtil.showMemberGift(mAct, new PopupUtil.OnViewClickListener() {
            @Override
            public void onClick(View view) {
                UserInfo loadUserBean = SpUtils.getInstance().getLoadUserBean();
                loadUserBean.getData().setIsFans(1);
                SpUtils.getInstance().putLoadUserBean(loadUserBean);
                SpUtils.getInstance().putIsFansCode();
//                Intent mFansGiftIntent = new Intent(mAct, FansGiftContentActivity.class);
//                mAct.startActivity(mFansGiftIntent);
//                mAct.finish();

            }
        });
    }


    public void sendJsAppointMap(Intent intent) {
        double mLatitude = intent.getDoubleExtra("latitude", 0);
        double mLongitude = intent.getDoubleExtra("longitude", 0);
        String mAddress = intent.getStringExtra("address");
        long mRange = intent.getLongExtra("range", 150);
        JsonObject mJsonObject = new JsonObject();
        mJsonObject.addProperty("latitude", mLatitude);
        mJsonObject.addProperty("longitude", mLongitude);
        mJsonObject.addProperty("address", mAddress);
        mJsonObject.addProperty("range", mRange);

        function.onCallBack(mJsonObject.toString());
    }    //创建监听权限的接口对象

    public void reloadWeb() {
        if (mWebView != null) {
            mWebView.reload();
        }
    }

    /**
     * 会员登记界面，通过H5界面跳转到新建地址界面
     *
     * @param bean
     */
    public void senJsNewAddress(UserAddressData.DataBean bean) {
        ReceivingAddressBean mReceivingAddressBean = new ReceivingAddressBean();
        ReceivingAddressBean.Address mAddress = new ReceivingAddressBean.Address();
        if (bean == null) {
            mReceivingAddressBean.setType(0);
            function.onCallBack(GsonUtils.toJson(mReceivingAddressBean));
            return;
        }
        mReceivingAddressBean.setType(1);

        ReceivingAddressBean.Address.AddressInfo mDistrictInfo = getAddressInfoBean(bean.getAreaThree());
        if (mDistrictInfo != null) {
            mAddress.setDistrict(new ReceivingAddressBean.Address.AddressInfo(mDistrictInfo.id, mDistrictInfo.name));
        }
        ReceivingAddressBean.Address.AddressInfo mCityInfo = getAddressInfoBean(bean.getAreaSecond());
        if (mCityInfo != null) {
            mAddress.setCity(new ReceivingAddressBean.Address.AddressInfo(mCityInfo.id, mCityInfo.name));
        }
        ReceivingAddressBean.Address.AddressInfo mProvinceInfo = getAddressInfoBean(bean.getAreaFirst());
        if (mProvinceInfo != null) {
            mAddress.setProvince(new ReceivingAddressBean.Address.AddressInfo(mProvinceInfo.id, mProvinceInfo.name));
        }
        mAddress.setId(bean.getId());
        mAddress.setName(bean.getName());
        mAddress.setPhone(bean.getPhone());
        mAddress.setAddress(bean.getAddress());
        mReceivingAddressBean.setAddress(mAddress);
        function.onCallBack(GsonUtils.toJson(mReceivingAddressBean));
    }

    /**
     * H5 调用新增地址，回传给H5
     *
     * @param bean
     */
    public void senJsNewAddAddress(ReceiveAddressBean bean) {
        ReceivingAddressBean mReceivingAddressBean = new ReceivingAddressBean();
        ReceivingAddressBean.Address mAddress = new ReceivingAddressBean.Address();
        if (bean == null) {
            mReceivingAddressBean.setType(0);
            function.onCallBack(GsonUtils.toJson(mReceivingAddressBean));
            return;
        }
        mReceivingAddressBean.setType(1);

        ReceivingAddressBean.Address.AddressInfo mDistrictInfo = getAddressInfoBean(bean.getAreaThree());
        if (mDistrictInfo != null) {
            mAddress.setDistrict(new ReceivingAddressBean.Address.AddressInfo(mDistrictInfo.id, mDistrictInfo.name));
        }
        ReceivingAddressBean.Address.AddressInfo mCityInfo = getAddressInfoBean(bean.getAreaSecond());
        if (mCityInfo != null) {
            mAddress.setCity(new ReceivingAddressBean.Address.AddressInfo(mCityInfo.id, mCityInfo.name));
        }
        ReceivingAddressBean.Address.AddressInfo mProvinceInfo = getAddressInfoBean(bean.getAreaFirst());
        if (mProvinceInfo != null) {
            mAddress.setProvince(new ReceivingAddressBean.Address.AddressInfo(mProvinceInfo.id, mProvinceInfo.name));
        }
        mAddress.setId(bean.getId());
        mAddress.setName(bean.getName());
        mAddress.setPhone(bean.getPhone());
        mAddress.setAddress(bean.getAddress());
        mReceivingAddressBean.setAddress(mAddress);
        function.onCallBack(GsonUtils.toJson(mReceivingAddressBean));
    }

    /**
     * 拨打电话（直接拨打电话）
     *
     * @param phoneNum 电话号码
     */
    public void callPhone(String phoneNum) {

        if (TextUtils.isEmpty(phoneNum)) {
            ToastUtils.showShort(mAct.getApplicationContext(), "手机号有误");
            return;
        } else {

            Intent intent = new Intent(Intent.ACTION_CALL);
            Uri data = Uri.parse("tel:" + phoneNum);
            intent.setData(data);
            mAct.startActivity(intent);
        }
    }

    private void getWineCoin(String ext) {
        if (!SpUtils.getInstance().getIsLogin())
            return;
        SendRequest.shareSuccessHandle(SpUtils.getInstance().getLoadUserBean().getData().getToken(), 8, ext, new StringCallback() {
            @Override
            public void onError(Call call, Exception e, int id) {
            }

            @Override
            public void onResponse(String response, int id) {
                try {
                    JSONObject json = new JSONObject(response);
                    boolean success = json.optBoolean("success");
                    if (success) {
                        try {
                            int coin = json.getInt("data");
                            if (coin > 0) {
                                DialogManager.showCoinDialog(mAct, "扫码成功", coin);
//                                updateUserInfo();
                            }
                        } catch (Exception e) {
                            e.getMessage();
                        }
                    }
                } catch (JSONException e) {
                    e.printStackTrace();
                }
            }
        });
    }

    /**
     * 打开订单详情
     *
     * @author: merbng
     * @time: 2021/10/25 9:24
     * @description:
     */
    @Override
    public void jumpOrderDetail(CallBackFunction function, JSData.ParamBean mParam) {
        Bundle bundle = new Bundle();
        bundle.putLong(Constants.KEY_ORDER_ID, mParam.getId());
        ActivityRouter.startActivity(ActivityRouter.NEW_RETAIL.ORDER_DETAIL, bundle);
    }

    /**
     * 打开售后订单详情
     *
     * @author: merbng
     * @time: 2021/10/25 9:24
     * @description:
     */
    @Override
    public void jumpAfterOrderDetail(CallBackFunction function, JSData.ParamBean mParam) {
        Bundle bundle = new Bundle();
        bundle.putLong("afterSalesId", mParam.getId());
        ActivityRouter.startActivity(ActivityRouter.NEW_RETAIL.AFTER_SALES_DETAILS, bundle);
    }

    //文化大使投票 分享海报弹窗
    @Override
    public void showSharePoster4oteRank(CallBackFunction function, JSData.ParamBean mParam) {
        Bundle bundle = new Bundle();
        bundle.putString("shareImage", mParam.getShareImgUrl());
        ActivityRouter.startActivity(ActivityRouter.ACTIVITY.H5_SHARE_VOTERANK, bundle);
    }

    @Override
    public void backPage(CallBackFunction function, JSData.ParamBean mParam) {
        EventBusUtils.sendNotify(MessageBus.msgid_web_back_page);
    }

    @Override
    public void hideTopTitle(CallBackFunction function, JSData.ParamBean mParam) {
        EventBusUtils.sendNotify(MessageBus.msgid_hide_top_title);
    }

    @Override
    public void showTopTitle(CallBackFunction function, JSData.ParamBean mParam) {
        EventBusUtils.sendNotify(MessageBus.msgid_show_top_title);
    }

    //禁用侧滑返回
    @Override
    public void banBack(CallBackFunction function, JSData.ParamBean mParam) {
        EventBusUtils.sendNotify(MessageBus.msgid_is_ban_back_page);
    }

    //选择搜索的酒窖
    public void sendJsSearchWineCellar(int id, String name) {
        JsonObject mJsonObject = new JsonObject();
        mJsonObject.addProperty("id", id);
        mJsonObject.addProperty("name", name);
        function.onCallBack(mJsonObject.toString());
    }

    //获取用户信息
    @Override
    public void getCurrentUserInfo(CallBackFunction function, JSData.ParamBean mParam) {
        if (SpUtils.getInstance().getLoadUserBean() != null) {
            SpUtils.getInstance().getLoadUserBean().getData();
            String json = CommonUtil.beanToJson(SpUtils.getInstance().getLoadUserBean().getData());
            function.onCallBack(json);
        }
    }

    //h5申请打开摄像头权限
    @Override
    public void openCameraPermission(CallBackFunction function, JSData.ParamBean mParam) {
        EventBusUtils.sendNotify(MessageBus.msgid_h5_apply_camera_permission);
    }

    //跳转商品详情
    @Override
    public void openGoodsDetail(CallBackFunction function, JSData.ParamBean mParam) {
        HashMap<String, Object> map2 = new HashMap<>();
        map2.put(Constants.GOODS_DETAIL_ID, mParam.getId());
        map2.put(Constants.GOODS_DETAIL_SOURCE, "其他");
        ARouterUtils.jump(ActivityRouter.NEW_RETAIL.GOODS_DETAUILS, map2);
    }

    @Override
    public void setStatusBarDark(CallBackFunction function, JSData.ParamBean mParam) {
        EventBusUtils.sendNotify(MessageBus.msgid_h5_apply_status_bar_dark);
    }

    @Override
    public void getUid(CallBackFunction function) {
        function.onCallBack(""+SpUtils.getInstance().getLoadUserBean().getData().getId());
    }
}
